package net.googlecode.harchenko.task5.calculator;

import net.googlecode.harchenko.task5.model.Person;

import java.math.BigDecimal;

/**
 * Class for creating salary calculator according to person type
 */
public class SalaryCalculatorFactory {

     private static final BigDecimal BOSS_TAX = new BigDecimal(500);
    private static final BigDecimal MANAGER_TAX = new BigDecimal(250);
    private static final BigDecimal EMPLOYEE_TAX = new BigDecimal(125);
    /**
     * Get calculator for person type
     *
     * @param person the manager
     * @return calculator for person type
     */
    public static Calculator getCalculator(Person person) {
        if (person.getType().equals(Person.MANAGER) ) {
            ManagerSalaryCalculator mng= new ManagerSalaryCalculator();
            mng.setTax(MANAGER_TAX);
            return mng;
        }
        else if ( person.getType().equals(Person.BOSS)){

           ManagerSalaryCalculator boss= new ManagerSalaryCalculator();
            boss.setTax(BOSS_TAX);
            return boss;
        }
        EmployeeSalaryCalculator emp = new EmployeeSalaryCalculator();
        emp.setTax(EMPLOYEE_TAX);
        return emp;
    }
}
